//
//  NSDictionary+EXNSDictionary.m
//  Pet
//
//  Created by Wendale on 13-9-15.
//  Copyright (c) 2013年 Wendale. All rights reserved.
//

#import "NSDictionary+EXNSDictionary.h"

@implementation NSDictionary (EXNSDictionary)

- (id)WValueForKey:(NSString*)key{
   id value =   [self valueForKey:key];
    if ([value isKindOfClass:[NSNull class]]) {
        return @"";
    }
    if ([value isKindOfClass:[NSNumber class]]) {
        return [NSString stringWithFormat:@"%@",value];
    }
    return value;
}

+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString {
    if (jsonString == nil) {
        return nil;
    }
    
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
                                                        options:NSJSONReadingMutableContainers
                                                          error:&err];
    if(err) {
        NSLog(@"json解析失败：%@",err);
        return nil;
    }
    return dic;
}

@end
